package org.example.classdemo.functioninterface;

import java.util.ArrayList;
import java.util.List;

public class EatApple {
    private final List<IApple> apples = new ArrayList<>();

    public void eatAction(String name){
        eat(name,(a)->{
            a.get();
        });
    }

    public void eat(String name, Consumer<IApple> appleConsumer){
        apples.add(new Apple());
        System.out.println(name);
        //this.apples.forEach(appleConsumer); 不能这样用,因为这是我自己定义的Consumer  不是java.util.function.Consumer
        this.apples.forEach(t->appleConsumer.andThen(v-> System.out.println("ddd")).accept(t));

    }

    public static void main(String[] args) {
        EatApple eatApple = new EatApple();
        eatApple.eatAction("kara");

    }

}
